<template>
    <div>
        <el-button type="primary" @click="login">登录</el-button>
        <el-button type="warning" @click="info">获取登录信息</el-button>
        <el-button type="danger" @click="logout">退出</el-button>
        <el-button type="success" @click="gotoTestVue">路由触发</el-button>
        <el-card :body-style="{'width':'50%','margin':'auto'}" shadow="hover">
            <el-input v-model="information.username"></el-input>
            <el-input v-model="information.password"></el-input>
            <el-input v-model="token"></el-input>
        </el-card>

        <el-button type="default" @click="log">日志</el-button>
    </div>

</template>

<script>
    import {postActionData} from "../../api/master";

    export default {
        name: "welcome",
        data() {
            return {
                message: {data: null},
                information: {},
                token: null,
                LogDto:{
                    operationKeyword: "用户",
                    usernameKeyword:"admin",
                    minTime: 68,
                    maxTime: 829,
                    startDatetime: "2020-9-29 13:46:20"
                }
            }
        },
        methods: {
            log() {
                postActionData("/log/getLogPage/1/10",
                    {
                        operationKeyword: "用户",
                        usernameKeyword:"roo",
                    }).then(result => {
                    console.log("日志数据", result.record);
                })
            },
            gotoTestVue() {
                this.$router.push({path: "/home/testRouter", query: {msg: "Hello Old King"}}).catch(() => {
                    this.$message.warning("出现跳转异常");
                });
            },
            info() {
                this.information.username = this.$store.getters.username;
                this.information.password = this.$store.getters.password;
                this.token = this.$store.getters.token;
            },
            login() {
                this.$store.dispatch('LOGIN', {username: "admin", password: "123456"}).then(() => {
                    this.$store.dispatch("LOGIN_INFO").catch(() => {
                        this.$message.warning("无法获取抓取用户信息！")
                    });
                }).catch(() => {
                    this.$message.warning("登录出现异常！")
                });
            },
            logout() {
                this.$store.dispatch("LOGOUT").then(() => {
                });
            }
        }

    }
</script>

<style scoped>

</style>
